package demo2;

import java.util.Random;

/**
 * @author Huangjin
 * @version 1.0
 * describe:
 * @date 2023/2/20 20:04
 */
public class VerificationCode {
    public static void main(String[] args) {
        String t = code(4);
        System.out.println("验证码："+t);
    }
    public static String code(int len){
        String b = "";
        char[] ch = {'A','B','C','D','E','F',
                'G','H','I','J','K','L','M','N','O','P','Q','R',
                'S','T','U','V','W','X','Y','Z','0','1','2','3',
                '4','5','6','7','8','9'};
        Random random = new Random();
        for (int i = 0; i < len; i++) {
            int index = random.nextInt(ch.length);
            b += ch[index];
        }
        return b;
    }
}
